{% extends 'base.html' %}

{% block title %}为角色分配权限 - Django RBAC 项目{% endblock %}

{% block content %}
<div class="container mx-auto px-4 py-8">
    <h1 class="text-2xl font-bold mb-6">为角色 "{{ role.name }}" 分配权限</h1>

    <form method="post" class="bg-white shadow-md rounded px-8 pt-6 pb-8 mb-4">
        {% csrf_token %}
        <div class="mb-6">
            {% for permission in all_permissions %}
            <div class="mb-2">
                <label class="inline-flex items-center">
                    <input type="checkbox" class="form-checkbox" name="permissions" value="{{ permission.id }}"
                        {% if permission in role_permissions %}checked{% endif %}>
                    <span class="ml-2">{{ permission.name }} ({{ permission.codename }})</span>
                </label>
            </div>
            {% endfor %}
        </div>
        <div class="flex items-center justify-between">
            <button class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline" type="submit">
                保存权限
            </button>
            <a href="{% url 'manage_roles' %}" class="inline-block align-baseline font-bold text-sm text-blue-500 hover:text-blue-800">
                返回角色列表
            </a>
        </div>
    </form>
</div>
{% endblock %}

